

package com.hazelcast.client.impl.protocol.task;

import com.hazelcast.client.impl.protocol.ClientMessage;
import com.hazelcast.client.impl.protocol.codec.ClientRemoveMigrationListenerCodec;
import com.hazelcast.instance.impl.Node;
import com.hazelcast.internal.nio.Connection;
import com.hazelcast.internal.partition.IPartitionService;

import java.security.Permission;
import java.util.UUID;
import java.util.concurrent.Future;

public class RemoveMigrationListenerMessageTask extends AbstractRemoveListenerMessageTask<UUID> {

    public RemoveMigrationListenerMessageTask(ClientMessage clientMessage, Node node, Connection connection) {
        super(clientMessage, node, connection);
    }

    @Override
    protected Future<Boolean> deRegisterListener() {
        IPartitionService service = getService(IPartitionService.SERVICE_NAME);
        return service.removeMigrationListenerAsync(parameters);
    }

    @Override
    protected UUID getRegistrationId() {
        return parameters;
    }

    @Override
    protected UUID decodeClientMessage(ClientMessage clientMessage) {
        return ClientRemoveMigrationListenerCodec.decodeRequest(clientMessage);
    }

    @Override
    protected ClientMessage encodeResponse(Object response) {
        return ClientRemoveMigrationListenerCodec.encodeResponse((Boolean) response);
    }

    @Override
    public String getServiceName() {
        return IPartitionService.SERVICE_NAME;
    }

    @Override
    public Permission getRequiredPermission() {
        return null;
    }

    @Override
    public String getDistributedObjectName() {
        return null;
    }

    @Override
    public String getMethodName() {
        return "removeMigrationListener";
    }

}
